# coding:utf-8
import tensorflow as tf
path=r"F:\Resources\model\ws3_keras_mobile_model_1127_no_tl.pb"        #pb文件位置和文件名
path=r"F:\Resources\model\dete3\frozen_inference_graph.pb"        #pb文件位置和文件名
# inputs=["Placeholder"]               #模型文件的输入节点名称
# classes=["Softmax"]            #模型文件的输出节点名称
# converter = tf.contrib.lite.TocoConverter.from_frozen_graph(path, inputs, classes)
# tflite_model=converter.convert()
# open("/home/zhang/anaconda3/model_pb.tflite", "wb").write(tflite_model)
# gf = tf.GraphDef()
# gf.ParseFromString(open(path,'rb').read())
# g = tf.get_default_graph()
# opts = g.get_operations()
# print(opts)
detection_graph = tf.Graph()
with detection_graph.as_default():
    od_graph_def = tf.GraphDef()
    # 载入pb文件
    with tf.gfile.GFile(path,'rb') as fid:
        serialized_graph=fid.read()
        # 解析内容
        od_graph_def.ParseFromString(serialized_graph)
        tf.import_graph_def(od_graph_def,name='')
print(detection_graph.get_operations())
# for n in gf.node:
#     print(n.name + "--------> " + n.op)